package com.test.rabbitmq.manager;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @ClassName RabbitMQManager
 * @Author lulei
 * @Data 2020/3/12 22:06
 */

/**
 * 这个注解的意思是把（把普通pojo实例化到spring容器中，相当于配置文件中的<bean id="" class=""/>
 */
@Component
public class RabbitMQManager {

    @Resource
    public RabbitTemplate rabbitTemplate;

    public void sendMsg() {

        rabbitTemplate.convertAndSend("queue-NO:10001","我要入列");

    }

    public void sendMsgByExchange() {

        rabbitTemplate.convertSendAndReceive("exchange-NO:20001","","我也要入列");

    }
}
